<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>jQ 版下拉框</title>
    <style>
      .nav {
        width: 400px;
        height: 30px;
        line-height: 30px;
        background-color: #eeeeee;
        margin: 0 auto;
      }
      .nav .item {
        float: left;
        padding: 0 28px;
      }
      .nav .item:hover {
        cursor: pointer;
      }
      li {
        list-style: none;
      }
      .one {
        position: relative;
      }
      .one .myUl {
        position: absolute;
        left: 0;
      }
      .two {
        position: relative;
      }
      .two .myUl {
        position: absolute;
        left: 0;
      }
      .three {
        position: relative;
      }
      .three .myUl {
        position: absolute;
        left: 0;
      }
      .four {
        position: relative;
      }
      .four .myUl {
        position: absolute;
        left: 0;
      }
      .myUl {
        display: none;
        width: 100px;
        height: 90px;
        padding-left: 0;
        margin-top: 0;
      }
      .myUl li {
        width: 100px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        border-bottom: 1px solid #eeeeee;
        box-sizing: border-box;
      }
    </style>
    <script src="lib/jQuery-v3.6.0.min.js"></script>
  </head>
  <body>
    <div class="nav">
      <div class="item one">
        三个字
        <ul class="myUl">
          <li>哈哈哈哈1</li>
          <li>嘿嘿嘿嘿1</li>
          <li>啦啦啦啦1</li>
        </ul>
      </div>

      <div class="item two">
        两字
        <ul class="myUl">
          <li>哈哈哈哈2</li>
          <li>嘿嘿嘿嘿2</li>
          <li>啦啦啦啦2</li>
        </ul>
      </div>
      <div class="item three">
        加油加油
        <ul class="myUl">
          <li>哈哈哈哈3</li>
          <li>嘿嘿嘿嘿3</li>
          <li>啦啦啦啦3</li>
        </ul>
      </div>
      <div class="item four">
        微博
        <ul class="myUl">
          <li>哈哈哈哈4</li>
          <li>嘿嘿嘿嘿4</li>
          <li>啦啦啦啦4</li>
        </ul>
      </div>
    </div>

    <script>
      $(function () {
        $('.one').mouseover(function () {
          $('.one > .myUl').css('display', 'block')
        })
        $('.one').mouseout(function () {
          $('.one > .myUl').css('display', 'none')
        })

        $('.two').mouseover(function () {
          $('.two > .myUl').css('display', 'block')
        })
        $('.two').mouseout(function () {
          $('.two > .myUl').css('display', 'none')
        })

        $('.three').mouseover(function () {
          $('.three > .myUl').css('display', 'block')
        })
        $('.three').mouseout(function () {
          $('.three > .myUl').css('display', 'none')
        })

        $('.four').mouseover(function () {
          $('.four > .myUl').css('display', 'block')
        })
        $('.four').mouseout(function () {
          $('.four > .myUl').css('display', 'none')
        })
      })
    </script>
  </body>
</html>
